import myRequest from '../request.js'

import dicts from '@/config/dicts.js'



// 获取轮播图
export const getAppBanner = (val) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.essential + `/common/setting/banner`, 'get', val).then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 当天秒杀活动
export const getNowSeckill = (activity_type) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + `/purchaser/promotion/${activity_type}/sections/current`, 'get').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 其他活动
export const getActivityList = (activity_type) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + `/purchaser/promotion/${activity_type}/current`, 'get').then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}


// 获取当前进行中的促销活动商品
export const getGoods = (url, val) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + url, 'get', val).then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 加入购物车
export const getCarts = (val) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + '/purchaser/trade/carts', 'post', val).then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
// 获取商品组合分页列表
export const getPortfolioList = (val) => {
  return new Promise((resolve, reject) => {
    myRequest(dicts.buyer + `/purchaser/goods/portfolio/get/page`, 'get', val).then(res => {
      resolve(res)
    }).catch((err) => {
      reject(err)
    })
  })
}
